package com.sxj.PDMS.controller.student;

import com.sxj.PDMS.common.BaseResponse;
import com.sxj.PDMS.common.Result;
import com.sxj.PDMS.model.entity.PartyMemberAwards;
import com.sxj.PDMS.model.entity.PartyMemberPunishments;
import com.sxj.PDMS.model.vo.PagingQueryResponse;
import com.sxj.PDMS.service.PartyMemberAwardsService;
import com.sxj.PDMS.service.PartyMemberPunishmentsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/student")
@Slf4j
public class StudentAwardsAndPunishmentController {
    @Autowired
    private PartyMemberAwardsService partyMemberAwardsService;
    @Autowired
    private PartyMemberPunishmentsService partyMemberPunishmentsService;
    @GetMapping("/selectAll_awards")
    public BaseResponse<PagingQueryResponse<PartyMemberAwards>> selectAwards(@RequestParam(defaultValue = "1") Integer page,
                                                                             @RequestParam(defaultValue = "10") Integer pageSize) {
        log.info("分页查询 ：page:{}, pageSize:{}", page, pageSize);
        PagingQueryResponse<PartyMemberAwards> pagingQueryResponse = partyMemberAwardsService.selectAll(page, pageSize);
        return Result.success(pagingQueryResponse);

    }

    @GetMapping("/select_awards")
    public BaseResponse<PagingQueryResponse<PartyMemberAwards>> selectAwardsWithCondition(@RequestParam(defaultValue = "1") Integer page,
                                                                                          @RequestParam(defaultValue = "10") Integer pageSize,
                                                                                          PartyMemberAwards partyMemberAwards) {

        PagingQueryResponse<PartyMemberAwards> pagingQueryResponse = partyMemberAwardsService.awardsSelect(page, pageSize, partyMemberAwards);

        return Result.success(pagingQueryResponse);
    }
    @GetMapping("/selectAll_punishments")
    public BaseResponse<PagingQueryResponse<PartyMemberPunishments>> selectPunishments(@RequestParam(defaultValue = "1") Integer page,
                                                                                       @RequestParam(defaultValue = "10") Integer pageSize) {
        log.info("分页查询 ：page:{}, pageSize:{}", page, pageSize);
        PagingQueryResponse<PartyMemberPunishments> pagingQueryResponse = partyMemberPunishmentsService.selectAll(page, pageSize);
        return Result.success(pagingQueryResponse);

    }

    @GetMapping("/select_punishments")
    public BaseResponse<PagingQueryResponse<PartyMemberPunishments>> selectPunishmentsWithCondition(@RequestParam(defaultValue = "1") Integer page,
                                                                                                    @RequestParam(defaultValue = "10") Integer pageSize,
                                                                                                    PartyMemberPunishments partyMemberPunishments) {

        PagingQueryResponse<PartyMemberPunishments> pagingQueryResponse = partyMemberPunishmentsService.punishmentsSelect(page, pageSize, partyMemberPunishments);

        return Result.success(pagingQueryResponse);
    }
}
